'use strict';
/**
 * Created by xgjiang on 2015-10-13.
 */
define([
        'angular',
        'app/modules/users/define',
        'app/modules/users/services/users',
        'app/modules/users/directives/users_login_unique'
    ],
    function(angular) {
        angular.module('ad.users')
            .controller('adUsersEditController',['$scope','$uibModalInstance','adUsersService','item',function($scope,$uibModalInstance,service,item) {
                item.user_password = '';
                $scope.item = item;
                $scope.ok = function () {
                    if(item.user_id == ''){
                        service.addItem($scope.item).then(function(data){
                            $uibModalInstance.close(data);
                        });
                    }else{
                        service.updateItem($scope.item).then(function(data){
                            $uibModalInstance.close(data);
                        });
                    }
                };

                $scope.cancel = function () {
                    $uibModalInstance.dismiss('cancel');
                };
            }]);
    });